package com.ego.coupon.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ego.common.util.PageUtil;
import com.ego.common.vo.PageVo;
import com.ego.coupon.vo.SeckillPromotionSearchVo;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import com.ego.coupon.dao.SeckillPromotionDao;
import com.ego.coupon.po.SeckillPromotion;
import com.ego.coupon.service.SeckillPromotionService;

/**
 * @program: ego
 * @description 秒杀活动对应实现类
 * @author KamTang
 * @date 2022-11-13 13:17:12
 */
@Service("seckillPromotionService")
public class SeckillPromotionServiceImpl extends ServiceImpl<SeckillPromotionDao, SeckillPromotion> implements SeckillPromotionService {
    @Override
    public PageVo<SeckillPromotion> search(SeckillPromotionSearchVo search) {
        LambdaQueryWrapper<SeckillPromotion> wrapper = Wrappers.<SeckillPromotion>lambdaQuery()
                .like(StringUtils.isNotEmpty(search.getKeyword()), SeckillPromotion::getTitle, search.getKeyword());
        Page<SeckillPromotion> page = baseMapper.selectPage(Page.of(search.getPageNum(), search.getPageSize()), wrapper);
        return PageUtil.toPage(page);
    }
}
